﻿/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Text;
using System.Data;
using OpenSISLoginBusinessLayer;
using OpenSISMenuBusinessLogic;
using OpenSISDropDownBusinessLogic;
using OpensisSchoolBusinessLayer;
using OpenSISPeriodBusinessLayer;
using OSISGradeLeveDataLayer;
using OSISGradeLevelBusinessLayer;
using OSISInstallationBusinessLayer;
using OpenSISPortalNotesBusinessLayer;
using OpenSISCalenderDetailsBusinessLayer;
using OSISStaffBusinessLayer;
using OSISStudentBusinessLayer;
using OSISStudentSetupBusinessLayer;
using OSISMarkingPeriodBusinessLayer;
using OSISEntryFormLayoutBusinessLayer;
using OSISDragNDropLayer;
using OSISStudentInfoBusinessLayer;
using OSISViewFormLayoutBusinessLayer;
using OSISStudentEditBusinessLayer;

using System.ServiceModel.Activation;
using OSISEthnicityBusinessLogic;

namespace WcfService1
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "OpenSISWCFService" in code, svc and config file together.
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant,InstanceContextMode = InstanceContextMode.Single)]
    //[ServiceBehavior(ConcurrencyMode= ConcurrencyMode.Multiple)]

    public class OpenSISWCFService : IServiceProperties, IOpenSISWCFServicePeriod, IOpenSISWCFServiceSchoolDetails, IOpenSISWCFServiceGradeLevel, IOpenSISWCFServiceInstallation, IOpenSISWCFServicePortalNotes, IOpenSISServiceCalendar, IOpenSISWCFServiceStaff, IOpenSISWCFServiceStudentSetup, IOpenSISServiceMarkingPeriod, IOpenSISWCFServiceStudentFormLayout, IOpenSISServiceDragDrop, IOpenSISWCFServiceStudentInformation, IOpenSISWCFStudentViewFormLayout, IopenSISServiceStudent, IOpenSISWCFServiceStudentEdit, IOpenSISWCFServiceTools
    {
        public bool WCFValidateAdmin(string Username, string Password)
        {

            LoginBL LogBL = new LoginBL();
            LogBL.Username = Username;
            LogBL.Password = Password;
            try
            {
                if (LogBL.ValidateAdmin())
                {
                    return true;

                }
                else
                {
                    return false;
                }
               
            }
            catch
            {
                return false;
            }

        }

        public DataTable SearchMainMenuItems()
        {
            MainMenuBL MMBL = new MainMenuBL();
            DataTable dtMainMenu = MMBL.SearchMainMenuItems();
            return dtMainMenu;
        }
       
        public DataTable SearchMainMenuSubMenuItems(string MMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;
            DataTable dtMainMenu = MMBL.SearchMainMenuSubMenuItems();
            return dtMainMenu;
        }

        public DataTable SearchMainMenuSubMenuChildItems(string MMenuheader, string MSMenuheader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuheader;
            MMBL.MSMenuHeader = MSMenuheader;
            DataTable dtMainMenu = MMBL.SearchMainMenuSubMenuChildItems();
            return dtMainMenu;
        }

        public DataTable SubMenuChildItemsUrl(string MSChildMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MSChildMenuHeader = MSChildMenuHeader;

            DataTable dtMainMenu = MMBL.SubMenuChildItemsUrl();
            return dtMainMenu;
        }

        public DataTable SubMenuItemsUrl(string MMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;

            DataTable dtMainMenu = MMBL.SubMenuItemsUrl();
            return dtMainMenu;
        }

        public DataTable MainMenuItemsUrl(string MMenuHeader)

        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;

            DataTable dtMainMenu = MMBL.MainMenuItemsUrl();
            return dtMainMenu;
        }

        public DataTable SearchMainMenuItemsMultilang(string Menutype, string languagetype)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MenuType = Menutype;
            MMBL.LanguageType = languagetype;

            DataTable dtMainMenu = MMBL.SearchMainMenuItemsMultilang();
            return dtMainMenu;
        }

        public DataTable MainMenuItemsUrlMultilang(string MMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;

            DataTable dtMainMenu = MMBL.MainMenuItemsUrlMultilang();
            return dtMainMenu;
        }

        public DataTable SearchSubMenuItemsMultilingual(string MMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;

            DataTable dtMainMenu = MMBL.SearchSubMenuItemsMultilingual();
            return dtMainMenu;
        }

        public DataTable SubMenuItemsUrlMultilingual(string MMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuHeader;

            DataTable dtMainMenu = MMBL.SubMenuItemsUrlMultilingual();
            return dtMainMenu;
        }

        public DataTable SearchSubMenuChildItemsMultilingual(string MMenuheader, string MSMenuheader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MMenuHeader = MMenuheader;
            MMBL.MSMenuHeader = MSMenuheader;

            DataTable dtMainMenu = MMBL.SearchSubMenuChildItemsMultilingual();
            return dtMainMenu;
        }

        public DataTable SubMenuChildItemsUrlMultilingual(string MSChildMenuHeader)
        {
            MainMenuBL MMBL = new MainMenuBL();
            MMBL.MSChildMenuHeader = MSChildMenuHeader;
           

            DataTable dtMainMenu = MMBL.SubMenuChildItemsUrlMultilingual();
            return dtMainMenu;
        }

        public DataSet PopulateSchool()
        {
            DropDownBL DDBL = new DropDownBL();
            DataSet ds = new DataSet();
            ds = DDBL.propulateSchool();
            return ds;
        }
        
        public DataSet PopulateFullYear(string School_ID)
        {
            DropDownBL DDBL = new DropDownBL();
            DDBL.Sch_ID = School_ID;
            DataSet ds = new DataSet();
            ds = DDBL.PopulateFullYear();
            return ds;
        }

        public DataSet PopulateLevel1(string School_Id, string School_Year)
        {
            DropDownBL DDBL = new DropDownBL();
            DDBL.Sch_ID = School_Id;
            DDBL.Sch_Year = School_Year;
            DataSet ds = new DataSet();
            ds = DDBL.PopulateLevel1();
            return ds;
        }        

        public DataTable PopulateSchoolPeriod(int Sch_Id, string Title, string Short_Name, string Short_Order, int Length, string Block, string Use_Attendance)
        {
            PeriodBL PBL = new PeriodBL();
            PBL.SchId = Sch_Id;
            PBL.Title = Title;
            PBL.ShortName = Short_Name;
            PBL.ShortOrder = Short_Order;
            PBL.Length = Length;
            PBL.Block = Block;
            PBL.UseAtted = Use_Attendance;

            DataTable dt = PBL.PopulateSchoolPeriod();
            return dt;
        }

        public void AddSchoolPeriod(int Sch_Id, string Title, string Short_Name, int Length, string Block, string Use_Attendance, string Start_Time, string End_Time)
        {
            PeriodBL PBL = new PeriodBL();
            PBL.SchId = Sch_Id;
            PBL.Title = Title;
            PBL.ShortName = Short_Name;
            PBL.Length = Length;
            PBL.Block = Block;
            PBL.UseAtted = Use_Attendance;
            PBL.StartTime = Start_Time;
            PBL.EndTime = End_Time;
            PBL.AddSchoolPeriod();
         
        }

        public void UpdatePeriod(string Title, string Short_Name, int Length, string Block, string Use_Attendance, string Start_Time, string End_Time, int Period_Id)
        {

            PeriodBL PBL = new PeriodBL();
          
            PBL.Title = Title;
            PBL.ShortName = Short_Name;
            PBL.Length = Length;
            PBL.Block = Block;
            PBL.UseAtted = Use_Attendance;
            PBL.StartTime = Start_Time;
            PBL.EndTime = End_Time;
            PBL.SchPeriodId = Period_Id;
            PBL.UpdatePeriod();

        }

        public void UpdateShortOrder(string Short_Order, int Sch_Period_Id)
        {
            PeriodBL PBL = new PeriodBL();
            PBL.SchPeriodId = Sch_Period_Id;
            PBL.ShortOrder = Short_Order;
            PBL.UpdateShortOrder();
        }

        public void DeletePeriod(int Sch_Period_Id)
        {
            PeriodBL PBL = new PeriodBL();
            PBL.SchPeriodId = Sch_Period_Id;
            PBL.DeletePeriod();
        }        

        public DataSet propulateState()
        {
            DropDownBL SCBL = new DropDownBL();

            DataSet ds = null;
            ds = SCBL.propulateState();
            return ds;
        }

        public DataSet propulateCountry()
        {
            DropDownBL scDl = new DropDownBL();

            DataSet ds = null;
            ds = scDl.propulateCountry();
            return ds;
        }      

        public void SchoolAdd(string ShortName, string SchoolName, string Address1, string Address2, string City, int State, string Zip, string Fax, string Phone, string Url, int CeebNum, string Type, string Level,  string PostZip, int PostState, string PostCity, string PostBox, string EmerPhone, string LastUpdated, string Email, string Principal, string BaseGradeScale, int Country, string PostBoxAddress1, string PostBoxAddress2, int PostBoxCountry)
        {
            SchoolBL scBl = new SchoolBL();
            scBl.ShortName = ShortName;
            scBl.SchoolName = SchoolName;
            scBl.Address1 = Address1;
            scBl.Address2 = Address2;
            scBl.City = City;
            scBl.State = State;
            scBl.Zip = Zip;
            scBl.Fax = Fax;
            scBl.Phone = Phone;
            scBl.Url = Url;
            scBl.CeebNum = CeebNum;
            scBl.Type = Type;

            scBl.Level = Level;
            //scBl.MinGrade = MinGrade;
            //scBl.MaxGrade = MaxGrade;
            scBl.PostZip = PostZip;
            scBl.PostState = PostState;
            scBl.PostCity = PostCity;

            scBl.PostBox = PostBox;
            scBl.EmerPhone = EmerPhone;
            scBl.LastUpdated = LastUpdated;
            scBl.Email = Email;
            scBl.Principal = Principal;
            scBl.BaseGradeScale = BaseGradeScale;
            scBl.Country = Country;
            scBl.PostBoxAddress1 = PostBoxAddress1;
            scBl.PostBoxAddress2 = PostBoxAddress2;
            scBl.PostBoxCountry = PostBoxCountry;
            scBl.SchoolAdd();
        }

       
        public void SchoolEdit(string ShortName, string SchoolName, string Address1, string Address2, string City, int State, string Zip, string Fax, string Phone, string Url, int CeebNum, string Type, string Level,  string PostZip, int PostState, string PostCity, string PostBox, string EmerPhone, string LastUpdated, string Email, string Principal, string BaseGradeScale, int Country, string PostBoxAddress1, string PostBoxAddress2, int PostBoxCountry, int SchoolID)
        {
            SchoolBL scBl = new SchoolBL();
            scBl.ShortName = ShortName;
            scBl.SchoolName = SchoolName;
            scBl.Address1 = Address1;
            scBl.Address2 = Address2;
            scBl.City = City;
            scBl.State = State;
            scBl.Zip = Zip;
            scBl.Fax = Fax;
            scBl.Phone = Phone;
            scBl.Url = Url;
            scBl.CeebNum = CeebNum;
            scBl.Type = Type;

            scBl.Level = Level;
            //scBl.MinGrade = MinGrade;
            //scBl.MaxGrade = MaxGrade;
            scBl.PostZip = PostZip;
            scBl.PostState = PostState;
            scBl.PostCity = PostCity;

            scBl.PostBox = PostBox;
            scBl.EmerPhone = EmerPhone;
            scBl.LastUpdated = LastUpdated;
            scBl.Email = Email;
            scBl.Principal = Principal;
            scBl.BaseGradeScale = BaseGradeScale;
            scBl.Country = Country;
            scBl.PostBoxAddress1 = PostBoxAddress1;
            scBl.PostBoxAddress2 = PostBoxAddress2;
            scBl.PostBoxCountry = PostBoxCountry;
            scBl.SchoolID = SchoolID;
            scBl.SchoolEdit();
        }

        public DataTable SearchSchool()
        {
            SchoolBL scBl = new SchoolBL();
            DataTable dt = scBl.SearchSchool();
            return dt;
        }

        public int MaxSchoolID()
        {
            SchoolBL scbl = new SchoolBL();
            scbl.MaxSchoolID();
            int i = scbl.SchoolID;
            return i;
        }

        public DataTable GetvalufromID(int schoolid)
        {
            SchoolBL scBL = new SchoolBL();
            scBL.SchoolID = schoolid;
            DataTable dt = scBL.GetvalufromID();
            return dt;
        }

        public DataSet propulate(int SchoolId)
        {
            SchoolBL SCBL = new SchoolBL();

            DataSet ds = null;
            SCBL.SchoolID = SchoolId;
            ds = SCBL.propulate();
            return ds;
        }

        public void UpdateMaxGrade(int MaxGrade, int SchoolID)
        {
            SchoolBL scBL = new SchoolBL();
            scBL.MaxGrade = MaxGrade;
            scBL.SchoolID = SchoolID;
            scBL.UpdateMaxGrade();
        }

        public void UpdateMinGrade(int MinGrade, int SchoolID)
        {
            SchoolBL scBL = new SchoolBL();
            scBL.MinGrade = MinGrade;
            scBL.SchoolID = SchoolID;
            scBL.UpdateMinGrade();
        }

        public DataTable PopulateGradeLevel(int School_ID)
        {
            DataTable dt = new DataTable();
            GradeLevelBL BL = new GradeLevelBL();
            BL.School_Id = School_ID;
            dt = BL.PopulateGradeLevel();
            return dt;
        }

        public void DeleteGradeLevel(int grd_lvl_id)
        {
            GradeLevelBL BL = new GradeLevelBL();
            BL.GrdLevelId = grd_lvl_id;
            BL.DeleteGradeLevel();
        }

        public void UpdateGradeLevel(string grd_lvl_short_nm, string grd_lvl_nm, int grd_lvl_id_next, string last_updated, int grd_lvl_id)
        {
            GradeLevelBL GLBL = new GradeLevelBL();
            GLBL.GrdLevelId = grd_lvl_id;
            GLBL.GradeLevelName = grd_lvl_nm;
            GLBL.GradeLevelShortName = grd_lvl_short_nm;
            GLBL.GrdLevelIdNext = grd_lvl_id_next;
            GLBL.LastUpdated = last_updated;
            GLBL.UpdateGradeLevel();
        }

        public string CheckTitleAndShortName()
        {
            GradeLevelBL GLBL = new GradeLevelBL();
            string value = GLBL.CheckTitleAndShortName();
            return value;
        }

        public DataTable GradeLevelDeleteCheck(int grd_lvl_id)
        {
            DataTable dt = new DataTable();
            GradeLevelBL GLBL = new GradeLevelBL();
            GLBL.GrdLevelId = grd_lvl_id;
            dt = GLBL.GradeLevelDeleteCheck();
            return dt;
        }

        public DataTable GradeLevelUseInNextGradeLevelCheck(int grd_lvl_id)
        {
            DataTable dt = new DataTable();
            GradeLevelBL GLBL = new GradeLevelBL();
            GLBL.GrdLevelId = grd_lvl_id;
            dt = GLBL.GradeLevelUseInNextGradeLevelCheck();
            return dt;
        }

        public void UpdateGradeShortOrder(string Grd_Short_Order, int Grd_Lvl_Id)
        {
            GradeLevelBL GLBL = new GradeLevelBL();
            GLBL.GrdLevelId = Grd_Lvl_Id;
            GLBL.GradeLevelShortOrder = Grd_Short_Order;
            GLBL.UpdateShortOrder();
        }

        public int PopulateMaxGradeLevelID(int School_id)
        {
            GradeLevelBL BL = new GradeLevelBL();
            BL.School_Id = School_id;
            BL.PopulateMaxGradeLevelID();
            int i = BL.GrdLevelId;
            return i;
        }

        public void AddGradeLevel(int Schoo_id, string Grade_Level_Name, string Grade_Level_Short_Name, int Grade_level_Next_Id, string Last_Update_Date)
        {
            GradeLevelBL GLBL = new GradeLevelBL();
            GLBL.School_Id = Schoo_id;
            GLBL.GradeLevelName = Grade_Level_Name;
            GLBL.GradeLevelShortName = Grade_Level_Short_Name;
            GLBL.GrdLevelIdNext = Grade_level_Next_Id;
            GLBL.LastUpdated = Last_Update_Date;
            GLBL.AddGradeLevel();

        }

        public DataSet PropulateNextGrade(int School_Id)
        {
            GradeLevelBL BL = new GradeLevelBL();
            DataSet dsNextGrade = new DataSet();
            BL.School_Id = School_Id;
            dsNextGrade = BL.PopulateNextGrade();
            return dsNextGrade;
        }

        public void PopulateMaxGradeLevelID()
        {
            throw new NotImplementedException();
        }

        //########################################################   Installation      ###########################################
        public void InsertInstalsettings(string Language, string Dateformat, string DatabaseType, string Server, string Databasename, string DatabaseUsername, string DatabasePassword, string Port, string AdminUsername, string AdminPassword, string TimeZone)
        {
            InstallationBL INBL = new InstallationBL();
            INBL.Language = Language;
            INBL.Dateformat = Dateformat;
            INBL.DatabaseType = DatabaseType;
            INBL.Server = Server;
            INBL.Databasename = Databasename;
            INBL.DatabaseUsername = DatabaseUsername;
            INBL.DatabasePassword = DatabasePassword;
            INBL.Port = Port;
            INBL.AdminUsername = AdminUsername;
            INBL.AdminPassword = AdminPassword;
            INBL.TimeZone = TimeZone;

            INBL.InsertInstalsettings();

        }

        public int AddSchoolName(string SchoolName)
        {
            InstallationBL INBL = new InstallationBL();
            INBL.SchoolName = SchoolName;

            int i = INBL.AddSchoolName();
            return i;
        }

        public DataTable getdateformat()
        {
            InstallationBL INBL = new InstallationBL();

            DataTable dt = INBL.getdateformat();
            return dt;
        }

        public DataTable getTimeJoneCode()
        {
            InstallationBL INBL = new InstallationBL();

            DataTable dt = INBL.getTimeJoneCode();
            return dt;
        }

        public int InsertBeginEndDateschooladd(string BeginDat, string EndDate, string SchoolYearName)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.BeginDate = BeginDat;
            INBl.EndDate = EndDate;
            INBl.SchoolYearName = SchoolYearName;
            int i = INBl.InsertBeginEndDateschooladd();
            return i;

        }

        public void InsertBeginEndDateintomarkinschooladd(string BeginDate, string EndDate, int Schoolid, int Schoolyrid)
        {
            InstallationBL INBL = new InstallationBL();

            INBL.BeginDate = BeginDate;
            INBL.EndDate = EndDate;
            INBL.Schoolid = Schoolid;
            INBL.Schoolyrid = Schoolyrid;
            INBL.InsertBeginEndDateintomarkinschooladd();
        }
        
        public void InsertintoSchoolspeccataddInstall(int SchoolId)
        {
            InstallationBL INBL = new InstallationBL();
            INBL.Schoolid = SchoolId;

            INBL.InsertintoSchoolspeccatadd();


        }
        
        public void InsertBeginEndDateintomarkin(string BeginDate, string EndDate, string Schoolid, string Schoolyrid)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.BeginDate = BeginDate;
            INBl.EndDate = EndDate;
            INBl.Schoolid = Convert.ToInt32(Schoolid);
            INBl.Schoolyrid = Convert.ToInt32(Schoolyrid);
            INBl.InsertBeginEndDateintomarkin();

        }

        public int AddGradeLevelInstall(string Gradename, int Schoolid)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.Gradename = Gradename;

            INBl.Schoolid = Convert.ToInt32(Schoolid);

            int i = INBl.AddGradeLevel();
            return i;
        }

        public void UpdateMaxGradeInstall(string Maxgrade, int Schoolid)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.Maxgrade = Convert.ToInt32(Maxgrade);

            INBl.Schoolid = Convert.ToInt32(Schoolid);

            INBl.UpdateMaxGrade();

        }

        public void UpdateMinGradeInstall(string Mingrade, string Schoolid)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.Mingrade = Convert.ToInt32(Mingrade);

            INBl.Schoolid = Convert.ToInt32(Schoolid);

            INBl.UpdateMinGrade();
        }

        public DataTable CheckMysqlDB(string Databasename, string Conn)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.Databasename = Databasename;

            INBl.Conn = Conn;

            DataTable dt = INBl.CheckMysqlDB();
            return dt;
        }

        public void InsertintoSchoolspeccatInstall(int Schoolid)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.Schoolid = Schoolid;



            INBl.InsertintoSchoolspeccat();

        }

        public int InsertBeginEnddate(string BeginDate, string EndDate, string SchoolYearName)
        {
            InstallationBL INBl = new InstallationBL();

            INBl.BeginDate = BeginDate;
            INBl.EndDate = EndDate;
            INBl.SchoolYearName = SchoolYearName;

            int i = INBl.InsertBeginEndDate();
            return i;

        }

        public void InsertConnectionSettings(string ConnectionString, string DatabaseType)
        {
            // InstallationBL INBL = new InstallationBL();

            string c = ConnectionString;
            string d = DatabaseType;

            string path = System.Web.Hosting.HostingEnvironment.MapPath("~/Web.config");

            //string path = System.IO.Path.GetPathRoot("~//App.config");

            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();

            xDoc.Load(path);

            System.Xml.XmlNodeList nodeList = xDoc.GetElementsByTagName("appSettings");

            System.Xml.XmlNodeList nodeAppSettings = nodeList[0].ChildNodes;


            System.Xml.XmlAttributeCollection xmlAttCollection = nodeAppSettings[0].Attributes;



            xmlAttCollection[0].InnerXml = "sqlConn"; // for key attribute

            xmlAttCollection[1].InnerXml = ConnectionString; // for value attribute


            System.Xml.XmlNodeList nodeAppSettingsserv = nodeList[0].ChildNodes;

            System.Xml.XmlAttributeCollection xmlAttCollectionserv = nodeAppSettingsserv[1].Attributes;


            xmlAttCollectionserv[0].InnerXml = "appserver"; // for key attribute

            xmlAttCollectionserv[1].InnerXml = DatabaseType;



            System.Xml.XmlNodeList nodeAppSettingscal = nodeList[0].ChildNodes;

            System.Xml.XmlAttributeCollection xmlAttCollectioncal = nodeAppSettingscal[2].Attributes;


            xmlAttCollectioncal[0].InnerXml = "calendarServer"; // for key attribute

            xmlAttCollectioncal[1].InnerXml = DatabaseType;


            xDoc.Save(path);
        }


        //########################################################   Installation      ###########################################

        public void PortalNotesadd(int SchoolID, string Title, string Notes, string VisibleStartDate, string Visibleenddate, string Visiblestaffid)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.SchoolID = SchoolID;
            PNBL.Title = Title;
            PNBL.Notes = Notes;
            PNBL.Visiblestartdate = VisibleStartDate;
            PNBL.Visibleenddate = Visibleenddate;
            PNBL.Visiblestaffid = Visiblestaffid;
            PNBL.PortalNotesadd();


        }

        public DataTable CheckSortOrderPortalNotes(int SchoolID, string Sortorder)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.SchoolID = SchoolID;
            PNBL.Sortorder = Sortorder;

            DataTable dt = PNBL.CheckSortOrder();
            return dt;

        }

        public DataTable PopulateStaffTypecheckbox()
        {
            PortalNotesBL PNBL = new PortalNotesBL();


            DataTable dt = PNBL.PopulateStaffTypecheckbox();
            return dt;
        }

        public DataTable PopulateSelectedStaffTypecheckbox(string VisibleStaffID)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.Visiblestaffid = VisibleStaffID;


            DataTable dt = PNBL.PopulateSelectedStaffTypecheckbox();
            return dt;
        }

        public DataTable PopulatePortalNotes(int SchoolId)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.SchoolID = SchoolId;


            DataTable dt = PNBL.PopulatePortalNotes();
            return dt;
        }

        public void DeletePortalNotes(int PortalNotesId)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.PortalNotesid = PortalNotesId;


            PNBL.DeletePortalNotes();

        }

        public void UpdatePortalNotes(string Title, string Notes, string Visiblestartdate, string Visibleenddate, string Visiblestaffid, int PortalNotesid)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.PortalNotesid = PortalNotesid;
            PNBL.Title = Title;
            PNBL.Notes = Notes;
            PNBL.Visiblestartdate = Visiblestartdate;
            PNBL.Visibleenddate = Visibleenddate;
            PNBL.Visiblestaffid = Visiblestaffid;
            PNBL.UpdatePortalNotes();
        }

        public void UpdateShortOrderportalNotes(string Sortorder, int PortalNotesid)
        {
            PortalNotesBL PNBL = new PortalNotesBL();
            PNBL.PortalNotesid = PortalNotesid;
            
            PNBL.Sortorder = Sortorder;

           

            PNBL.UpdateShortOrder();
        }


        //############################################# Calendar Section Starts Here ##########################################

        public int AddCalenderDetails(string DefaultTag, string CalenderName, string FromDate, string ToDate, int SchoolID, string LastUpdated)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.DefaultTag = DefaultTag;
            CalBL.CalenderName = CalenderName;
            CalBL.FromDate = FromDate;
            CalBL.ToDate = ToDate;
            CalBL.SchoolID = SchoolID;
            CalBL.LastUpdated = LastUpdated;

            int calenderid = CalBL.AddCalenderDetails();

            return calenderid;

        }

        public void UpdateCalenderDetails(string DefaultTag, string CalenderName, string FromDate, string ToDate, int SchoolID, string LastUpdated, int CalendarID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.DefaultTag = DefaultTag;
            CalBL.CalenderName = CalenderName;
            CalBL.FromDate = FromDate;
            CalBL.ToDate = ToDate;
            CalBL.SchoolID = SchoolID;
            CalBL.LastUpdated = LastUpdated;
            CalBL.CalenderID = CalendarID;

            CalBL.UpdateCalenderDetails();


        }

        public DataTable PopulateCalenderDetails(int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();
            CalBL.SchoolID = SchoolID;
            DataTable dt = CalBL.PopulateCalenderDetails();
            return dt;
        }

        public void UpdateShortOrderCalendarDetails(string SortOrder, int CalenderID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();
            CalBL.SortOrder = SortOrder;
            CalBL.CalenderID = CalenderID;
            CalBL.UpdateShortOrder();
        }

        public void DeleteCalDetails(int CalenderID,int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();
            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.DeleteCalDetails();
        }

        public void AddCalDaySchedule(int CalenderID, int SchoolID, string ScheduleDay, string StartTime, string EndTime)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();
            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.ScheduleDay = ScheduleDay;
            CalBL.StartTime = StartTime;
            CalBL.EndTime = EndTime;
            CalBL.AddCalDaySchedule();
        }

        public void DeleteCalDaySchedule(int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;

            CalBL.DeleteCalDaySchedule();
        }

        public DataTable PopulateCalenderDaySchedule(int SchoolID, int CalenderID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;

            DataTable dt = CalBL.PopulateCalenderDaySchedule();
            return dt;
        }

        public DataTable PopulateCalenderWeekEndDaySchedule(int SchoolID, int CalenderID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;

            DataTable dt = CalBL.PopulateCalenderWeekEndDaySchedule();
            return dt;
        }

        public DataTable CheckWeekEndDay(string CalWeekEndDay, int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.CalWeekEndDay = CalWeekEndDay;

            DataTable dt = CalBL.CheckWeekEndDay();
            return dt;
        }

        public void AddCalWeekEndDaySchedule(int CalenderID, int SchoolID, string CalWeekEndDay)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.CalWeekEndDay = CalWeekEndDay;

            CalBL.AddCalWeekEndDaySchedule();

        }

        public void DeleteCalWeekEndDaySchedule(int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;


            CalBL.DeleteCalWeekEndDaySchedule();
        }

        public DataTable CheckHoliday(int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;

            DataTable dt = CalBL.CheckHoliday();
            return dt;
        }

        public DataTable CheckSchoolDay(int CalenderID, int SchoolID, string EventDate)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.EventDate = EventDate;

            DataTable dt = CalBL.CheckSchoolDay();
            return dt;
        }

        public DataTable CheckHolidayforschlevent(int CalenderID, int SchoolID, string EventDate)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            CalBL.EventDate = EventDate;

            DataTable dt = CalBL.CheckHolidayforschlevent();
            return dt;
        }

        public DataTable Checkschlwrtweekend(int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();

            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;


            DataTable dt = CalBL.Checkschlwrtweekend();
            return dt;
        }

        //################################################# Calendar Section Ends Here ###########################################


        //################################################# Staff Section Goes Here ###########################################
        
        public DataSet PopulateEthnicity()
        {
            DataSet dsEthinicity = new DataSet();
            StaffBL STBL = new StaffBL();
            dsEthinicity = STBL.PopulateEthnicity();
            return dsEthinicity;
        }

        public DataSet PopulateLanguage()
        {
            DataSet dsLanguage = new DataSet();
            StaffBL STBL = new StaffBL();
            dsLanguage = STBL.PopulateLanguage();
            return dsLanguage;
        }

        public DataSet PopulateState()
        {
            DataSet dsState = new DataSet();
            StaffBL STBL = new StaffBL();
            dsState = STBL.PopulateState();
            return dsState;
        }

        public DataSet PopulateStaffType()
        {
            DataSet dsStaffType = new DataSet();
            StaffBL STBL = new StaffBL();
            dsStaffType = STBL.PopulateStaffType();
            return dsStaffType;
        }

        public DataSet PopulateSchools()
        {
            DataSet dsSchools = new DataSet();
            StaffBL STBL = new StaffBL();
            dsSchools = STBL.PopulateSchools();
            return dsSchools;
        }

        public DataSet PopulateSchoolsCheckbox()
        {
            DataSet dsSchoolsCheckbox = new DataSet();
            StaffBL STBL = new StaffBL();
            dsSchoolsCheckbox = STBL.PopulateSchoolsCheckbox();
            return dsSchoolsCheckbox;
        }

        public DataSet PopulateGender()
        {
            DataSet dsGender = new DataSet();
            StaffBL STBL = new StaffBL();
            dsGender = STBL.PopulateGender();
            return dsGender;
        }

        public string GenerateRandomNumber()
        {
            StaffBL STBL = new StaffBL();
            string Number = STBL.GenerateRandomNumber(9);
            return Number;
        }

        //public int InsertStaffDetails(string Language, string Gender, string Ethnicity, string FirstName, string MiddleName, string LastName, string DOB, string LastUpdated, string StaffIdNumber, string Alternateid, string Salutation, string Suffix, string Secondlang, string Thirdlang, string Disability, string Disabilitydesc)
        //{
               
        //}

        public void InsertStaffAddressDetails(int StaffId, string PrimaryAddress1, string PrimaryAddress2, string PrimaryCity, string PrimaryState, string PrimaryZip, string SecondaryAddress1, string SecondaryAddress2, string SecondaryCity, string SecondaryState, string SecondaryZip, string LastUpdated, string PoBox)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.PrimaryAddress1 = PrimaryAddress1;
            STABL.PrimaryAddress2 = PrimaryAddress2;
            STABL.PrimaryCity = PrimaryCity;
            STABL.PrimaryState = PrimaryState;
            STABL.PrimaryZip = PrimaryZip;
            STABL.SecondaryAddress1 = SecondaryAddress1;
            STABL.SecondaryAddress2 = SecondaryAddress2;
            STABL.SecondaryCity = SecondaryCity;
            STABL.SecondaryState = SecondaryState;
            STABL.SecondaryZip = SecondaryZip;
            STABL.LastUpdated = LastUpdated;
            STABL.PoBox = PoBox;
            STABL.InsertStaffAddressDetails();
        }

        public void InsertStaffPhoneDetails(int StaffId, string LastUpdated, string HomePhone, string MobilPhone, string Officphone, string WorkEmail, string Personalemail)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.LastUpdated = LastUpdated;
            STABL.HomePhone = HomePhone;
            STABL.MobilPhon = MobilPhone;
            STABL.Officphon = Officphone;
            STABL.WorkEmail = WorkEmail;
            STABL.Personalemail = Personalemail;
            STABL.InsertStaffPhoneDetails();
        }

        public void InsertStaffSchoolJoinDetails(int HomeSchoolId, int StaffId, string JoiningDate, string LeftDate, string LastUpdated, string Jobtitle, string StaffType)
        {
            StaffBL STABL = new StaffBL();
            STABL.HomeSchoolId = HomeSchoolId;
            STABL.StaffId = StaffId;
            STABL.JoiningDate = JoiningDate;
            STABL.LeftDate = LeftDate;
            STABL.LastUpdated = LastUpdated;
            STABL.Jobtitle = Jobtitle;
            STABL.StaffType = StaffType;
            STABL.InsertStaffSchoolJoinDetails();
        }

        public void InsertStaffAccessDetails(int StaffId, string Username, string Password, string LastUpdated, string SecretQuestn, string SecretAnswr, string OpensisAcces, string SchoolAccess)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.Username = Username;
            STABL.Password = Password;
            STABL.LastUpdated = LastUpdated;
            STABL.SecretQuestn = SecretQuestn;
            STABL.SecretAnswr = SecretAnswr;
            STABL.OpensisAcces = OpensisAcces;
            STABL.SchoolAccess = SchoolAccess;
            STABL.InsertStaffAccessDetails();
        }

        public void InsertStaffLibraryDetails(int StaffId, string LibraryCard, string LibraryClass, string Status, string LibraryAccess)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.LibraryCard = LibraryCard;
            STABL.LibraryClass = LibraryClass;
            STABL.Status = Status;
            STABL.LibraryAccess = LibraryAccess;
            STABL.InsertStaffLibraryDetails();
        }

        public void InsertStaffEmergncyContact(int StaffId, string Emrgnfirstnam, string Emrgnlastnam, string Emrgnrelationship, string EmrgnHomePhon, string EmrgnMobilePhon, string EmrgnWorkPhon, string Emrgnemail)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.Emrgnfirstnam = Emrgnfirstnam;
            STABL.Emrgnlastnam = Emrgnlastnam;
            STABL.Emrgnrelationship = Emrgnrelationship;
            STABL.EmrgnHomePhon = EmrgnHomePhon;
            STABL.EmrgnMobilePhon = EmrgnMobilePhon;
            STABL.EmrgnWorkPhon = EmrgnWorkPhon;
            STABL.Emrgnemail = Emrgnemail;
            STABL.InsertStaffEmergncyContact();
        }

        public void InsertStaffCertificateDetails(int StaffId, string CertDate, string CertExpirDate, string CertCode, string CertShortName, string CertName, string Primarycert, string LastUpdated, string CertDescription)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.CertDate = CertDate;
            STABL.CertExpirDate = CertExpirDate;
            STABL.CertCode = CertCode;
            STABL.CertShortName = CertShortName;
            STABL.CertName = CertName;
            STABL.Primarycert = Primarycert;
            STABL.LastUpdated = LastUpdated;
            STABL.CertDescription = CertDescription;
            STABL.InsertStaffCertificateDetails();
        }

        public void savestaffphoto(int StaffId, int HomeSchoolId, string PhotoUrl)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.HomeSchoolId = HomeSchoolId;
            STABL.PhotoUrl = PhotoUrl;
            STABL.savestaffphoto();
        }

        public DataTable PopulateStaffBySchoolID(int SchoolId, string FirstName, string LastName, string Username)
        {
            DataTable dt = new DataTable();
            StaffBL STABL = new StaffBL();
            STABL.SchoolId = SchoolId;
            STABL.FirstName = FirstName;
            STABL.LastName = LastName;
            STABL.Username = Username;
            dt = STABL.PopulateStaffBySchoolid();
            return dt;
        }

        



        public int InsertStaffDetails(string Language, string Gender, string Ethnicity, string FirstName, string MiddleName, string LastName, string DOB, string LastUpdated, string StaffIdNumber, string Alternateid, string Salutation, string Suffix, string Secondlang, string Thirdlang, string Disability, string Disabilitydesc)
        {
            StaffBL STABL = new StaffBL();
            int StaffId = 0;            
            STABL.Language = Language;
            STABL.Gender = Gender;
            STABL.Ethnicity = Ethnicity;
            STABL.FirstName = FirstName;  
            STABL.MiddleName = MiddleName;
            STABL.LastName = LastName;
            STABL.DOB = DOB;
            STABL.StaffIdNumber = StaffIdNumber;
            STABL.Alternateid = Alternateid;
            STABL.Salutation = Salutation;
            STABL.Suffix = Suffix;
            STABL.Secondlang = Secondlang;
            STABL.Thirdlang = Thirdlang;   
            STABL.Disability = Disability;
            STABL.Disabilitydesc = Disabilitydesc;
            StaffId = STABL.InsertStaffDetails();
            return StaffId;
        }


        public DataTable PopulateStaffdetails(int SchoolId, int StaffId)
        {
            StaffBL STABL = new StaffBL();
            STABL.SchoolId = SchoolId;
            STABL.StaffId = StaffId;
            DataTable dt = new DataTable();
            dt = STABL.PopulateStaffdetails();
            return dt;
        }

        public DataTable PopulateSchoolaccesschkbox(string SchoolAccess)
        {
            StaffBL STABL = new StaffBL();
            STABL.SchoolAccess = SchoolAccess;
            DataTable dt = STABL.PopulateSchoolaccesschkbox();
            return dt;
        }

        public DataTable PopulateCertification(int StaffID)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffID;
            DataTable dt = STABL.PopulateCertification();
            return dt;
        }

        public DataTable PopulatestaffPhoto(int StaffId, int HomeSchoolID)
        {
            StaffBL STABL = new StaffBL();
            STABL.StaffId = StaffId;
            STABL.HomeSchoolId = HomeSchoolID;
            DataTable dt = STABL.PopulatestaffPhoto();
            return dt;
        }

       

        //########################################################################################################################





        public DataTable GetNextStaffId(int StaffID, int SchoolID)
        {
            DataTable dt = new DataTable();
            StaffBL STAFBL = new StaffBL();
            STAFBL.StaffId = StaffID;
            STAFBL.SchoolId = SchoolID;            
            dt = STAFBL.GetNextStaffId();
            return dt;
        }


        public DataSet GetPreviousStaffId(int StaffIID, int SchoolIID)
        {
            DataSet ds = new DataSet();
            //DataTable dtP = new DataTable();
            StaffBL STAFBL = new StaffBL();
            STAFBL.StaffId = StaffIID;
            STAFBL.SchoolId = SchoolIID;           
            ds = STAFBL.GetPreviousStaffId();            
            return ds;
        }


        public DataTable GetFirstStudentIdBySchoolId(int SchoolIID)
        {
            DataTable dt = new DataTable();          
            StaffBL STAFBL = new StaffBL();
            STAFBL.SchoolId = SchoolIID;
            dt = STAFBL.GetFirstStudentIdBySchoolId();
            return dt;
        }


        public DataTable GetLastStaffIdBySchoolId(int SchoolIID)
        {
            DataTable dt = new DataTable();
            StaffBL STAFBL = new StaffBL();
            STAFBL.SchoolId = SchoolIID;
            dt = STAFBL.GetLastStaffIdBySchoolId();
            return dt;
        }

        public DataTable PopulateStaffdetailsEdit(int SchoolId, int StaffId)
        {
            DataTable dt = new DataTable();
            StaffBL STAFBL = new StaffBL();
            STAFBL.SchoolId = SchoolId;
            STAFBL.StaffId = StaffId;
            dt = STAFBL.PopulateStaffdetailsEdit();
            return dt;
        }


        public void UpdateStaffDetails(string Language, string Gender, string Ethnicity, string FirstName, string MiddleName, string LastName, string DOB, string LastUpdated, string StaffIdNumber, string Alternateid, string Salutation, string Suffix, string Secondlang, string Thirdlang, string Disability, string Disabilitydesc, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.Language = Language;
            STAFBL.Gender = Gender;
            STAFBL.Ethnicity = Ethnicity;
            STAFBL.FirstName = FirstName;
            STAFBL.MiddleName = MiddleName;
            STAFBL.LastName = LastName;
            STAFBL.DOB = DOB;
            STAFBL.LastUpdated = LastUpdated;
            STAFBL.StaffIdNumber = StaffIdNumber;
            STAFBL.Alternateid = Alternateid;
            STAFBL.Salutation = Salutation;
            STAFBL.Suffix = Suffix;
            STAFBL.Secondlang = Secondlang;
            STAFBL.Thirdlang = Thirdlang;
            STAFBL.Disability = Disability;
            STAFBL.Disabilitydesc = Disabilitydesc;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffDetails();

        }

        public void UpdateStaffaddressDetails(string PrimaryAddress1, string PrimaryAddress2, string PrimaryCity, string PrimaryState, string PrimaryZip, string SecondaryAddress1, string SecondaryAddress2, string SecondaryCity, string SecondaryState, string SecondaryZip, string PoBox, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.PrimaryAddress1 = PrimaryAddress1;
            STAFBL.PrimaryAddress2 = PrimaryAddress2;
            STAFBL.PrimaryCity = PrimaryCity;
            STAFBL.PrimaryState = PrimaryState;
            STAFBL.PrimaryZip = PrimaryZip;
            STAFBL.SecondaryAddress1 = SecondaryAddress1;
            STAFBL.SecondaryAddress2 = SecondaryAddress2;
            STAFBL.SecondaryCity = SecondaryCity;
            STAFBL.SecondaryState = SecondaryState;
            STAFBL.SecondaryZip = SecondaryZip;
            STAFBL.PoBox = PoBox;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffaddressDetails();
        }

        public void UpdateStaffphoneDetails(string HomePhone, string MobilPhon, string Officphon, string WorkEmail, string Personalemail, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.HomePhone = HomePhone;
            STAFBL.MobilPhon = MobilPhon;
            STAFBL.Officphon = Officphon;
            STAFBL.WorkEmail = WorkEmail;
            STAFBL.Personalemail = Personalemail;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffphoneDetails();
        }

        public void UpdateStaffschooljoinDetails(int HomeSchoolId, string JoiningDate, string LeftDate, string Jobtitle, string StaffType, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.HomeSchoolId = HomeSchoolId;
            STAFBL.JoiningDate = JoiningDate;
            STAFBL.LeftDate = LeftDate;
            STAFBL.Jobtitle = Jobtitle;
            STAFBL.StaffType = StaffType;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffschooljoinDetails();
        }

        public void UpdateStaffaccessDetails(string Username, string Password, string SecretQuestn, string SecretAnswr, string OpensisAcces, string SchoolAccess, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.Username = Username;
            STAFBL.Password = Password;
            STAFBL.SecretQuestn = SecretQuestn;
            STAFBL.SecretAnswr = SecretAnswr;
            STAFBL.OpensisAcces = OpensisAcces;
            STAFBL.SchoolAccess = SchoolAccess;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffaccessDetails();
        }

        public int CheckLibAccessbyStaffid(int StaffID)
        {
            StaffBL STAFBL = new StaffBL();
            int i = STAFBL.CheckLibAccessbyStaffid();
            return i;
        }

        public void UpdateStafflibaccessDetails(string LibraryCard, string LibraryClass, string Status, string LibraryAccess, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.LibraryAccess = LibraryAccess;
            STAFBL.LibraryCard = LibraryCard;
            STAFBL.LibraryClass = LibraryClass;
            STAFBL.Status = Status;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStafflibaccessDetails();

        }

        public void UpdateStaffemergencyDetails(string Emrgnfirstnam, string Emrgnlastnam, string Emrgnrelationship, string EmrgnHomePhon, string EmrgnMobilePhon, string EmrgnWorkPhon, string Emrgnemail, int StaffId)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.Emrgnfirstnam = Emrgnfirstnam;
            STAFBL.Emrgnlastnam = Emrgnlastnam;
            STAFBL.Emrgnrelationship = Emrgnrelationship;
            STAFBL.EmrgnHomePhon = EmrgnHomePhon;
            STAFBL.EmrgnMobilePhon = EmrgnMobilePhon;
            STAFBL.EmrgnWorkPhon = EmrgnWorkPhon;
            STAFBL.Emrgnemail = Emrgnemail;
            STAFBL.StaffId = StaffId;
            STAFBL.UpdateStaffemergencyDetails();
        }

        public void UpdateStaffcertificationDetails(string CertDate, string CertExpirDate, string CertCode, string CertShortName, string CertName, string Primarycert, string CertDescription, int StaffId, string Certificateid)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.CertDate = CertDate;
            STAFBL.CertExpirDate = CertExpirDate;
            STAFBL.CertCode = CertCode;
            STAFBL.CertShortName = CertShortName;
            STAFBL.CertName = CertName;
            STAFBL.Primarycert = Primarycert;
            STAFBL.CertDescription = CertDescription;
            STAFBL.StaffId = StaffId;
            STAFBL.Certificateid = Certificateid;
            STAFBL.UpdateStaffcertificationDetails();
        }

        public void Updatestaffphoto(int StaffID, int HomeSchID, string PhotoURL)
        {
            StaffBL STAFBL = new StaffBL();
            STAFBL.StaffId = StaffID;
            STAFBL.HomeSchoolId = HomeSchID;
            STAFBL.PhotoUrl = PhotoURL;
            STAFBL.Updatestaffphoto();       
        }

        //#######################################   Marking Period ###############################################
        public DataTable PopulateMarkingPeriodDetails(int SchId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();
            MPBL.SchId = SchId;
            DataTable dt = MPBL.PopulateSchoolYear();
            return dt;
        }

        public int InsertintoSchoolYear(string MPStartDate, string MPEndDate, string SchyrShortName, string SchyrName, int SchyrYear, string LastUpdate, int SchyrNextYear, int SchyrPrevYear, int YearTypeId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();
            MPBL.MPStartDate = MPStartDate;
            MPBL.MPEndDate = MPEndDate;
            MPBL.SchyrShortName = SchyrShortName;
            MPBL.SchyrName = SchyrName;
            MPBL.SchyrYear = SchyrYear;
            MPBL.LastUpdate = LastUpdate;
            MPBL.SchyrNextYear = SchyrNextYear;
            MPBL.SchyrPrevYear = SchyrPrevYear;
            MPBL.YearTypeId = YearTypeId;

            int i = MPBL.AddSchoolYear();

            return i;

        }

        public void InsertintoMarkingPeriod(string MarkingPeriodType, string MPStartDate, string MPEndDate, string MPAttendenceInd, string MPGradeInd, string MPGrdStartDate, string MPGrdEndDate, int SchId, int SchyrId, string MarkingPeriodName, string MPShortName, string LastUpdate)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();
            MPBL.MarkingPeriodType = MarkingPeriodType;
            MPBL.MPStartDate = MPStartDate;
            MPBL.MPEndDate = MPEndDate;
            MPBL.MPAttendenceInd = MPAttendenceInd;
            MPBL.MPGradeInd = MPGradeInd;
            MPBL.LastUpdate = LastUpdate;
            MPBL.MPGrdStartDate = MPGrdStartDate;
            MPBL.MPGrdEndDate = MPGrdEndDate;
            MPBL.SchId = SchId;
            MPBL.SchyrId = SchyrId;
            MPBL.MarkingPeriodName = MarkingPeriodName;
            MPBL.MPShortName = MPShortName;

            MPBL.AddMarkingPeriod();
        }

        public int ReturnMarkingPeriodTypeId(string MarkingPeriodType)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();
            MPBL.MarkingPeriodType = MarkingPeriodType;


            int i = MPBL.ReturnMarkingPeriodTypeId();
            return i;
        }

        public DataTable PopulateMarkingPeriodAll(int SchId, string MarkingPeriodType, int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();
            MPBL.MarkingPeriodType = MarkingPeriodType;
            MPBL.SchId = SchId;
            MPBL.SchyrId = SchyrId;


            DataTable dt = MPBL.PopulateMarkingPeriod();
            return dt;
        }

        public DataTable PopulateDetails(int SchId, int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchId = SchId;
            MPBL.SchyrId = SchyrId;


            DataTable dt = MPBL.PopulatePeriodDetails();
            return dt;
        }

        public DataTable PopulateSchoolYearName(int SchId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchId = SchId;
            DataTable dt = MPBL.PopulateSchoolYearName();
            return dt;
        }

        public void UpdateMarkingPeriod(string MPStartDate, string MPEndDate, string LastUpdate, string SchyrName, int SchyrId, string MPGradeInd, string MPGrdStartDate, string MPGrdEndDate, string MarkingPeriodName, string MPShortName, int MarkingPeriodId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.MPStartDate = MPStartDate;
            MPBL.MPEndDate = MPEndDate;
            MPBL.LastUpdate = LastUpdate;
            MPBL.SchyrName = SchyrName;
            MPBL.SchyrId = SchyrId;
            MPBL.MPGradeInd = MPGradeInd;
            MPBL.MPGrdStartDate = MPGrdStartDate;
            MPBL.MPGrdEndDate = MPGrdEndDate;
            MPBL.MarkingPeriodName = MarkingPeriodName;
            MPBL.MPShortName = MPShortName;
            MPBL.MarkingPeriodId = MarkingPeriodId;

            MPBL.UpdateMarkingPeriod();

        }

        public DataTable ReturnSchoolYearId(int SchId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchId = SchId;

            DataTable dt = MPBL.ReturnSchoolYearId();
            return dt;

        }

        public DataTable PopulateMarkingPeriodAfterUpdate(int SchId, int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchId = SchId;
            MPBL.SchyrId = SchyrId;

            DataTable dt = MPBL.PopulateMPAfterUpdate(SchId, SchyrId);
            return dt;
        }

        public DataTable PopulateALLMPDetails(int SchId, int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchId = SchId;
            MPBL.SchyrId = SchyrId;

            DataTable dt = MPBL.PopulateAllMPDetails();
            return dt;
        }

        public void DeleteMarkingPeriod(int MarkingPeriodId, int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.MarkingPeriodId = MarkingPeriodId;
            MPBL.SchyrId = SchyrId;

            MPBL.DeleteMarkingPeriod();
        }

        public DataTable Populatemarkingperiodforedit(int MarkingPeriodId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.MarkingPeriodId = MarkingPeriodId;


            DataTable dt = MPBL.PopulateMarkingPeriodForEdit();
            return dt;
        }

        public DataTable getchildcount(int SchyrId)
        {
            MarkingPeriodBL MPBL = new MarkingPeriodBL();

            MPBL.SchyrId = SchyrId;


            DataTable dt = MPBL.GetChildCount();
            return dt;
        }


        //#######################################   Marking Period ###############################################





        //=======================================  STUDENT SETUP ======================================================

        public DataTable GetSchoolSpecificCategory(string SchoolId, string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentBL STUBL = new StudentBL();
            STUBL.LangTool = LanguageTool;
            STUBL.SchoolID =Int32.Parse(SchoolId);
            dt = STUBL.GetSchoolSpecificCategory();
            return dt;
        }

        public DataSet populateUserControls()
        {
            DataSet ds = new DataSet();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            ds = StSetupBL.populateUserControls();
            return ds;
        }

        public DataSet populateCategory(int SchoolID,string LanguageTool)
        {
            DataSet ds = new DataSet();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolID;
            StSetupBL.LangTool = LanguageTool;
            ds = StSetupBL.populateCategory();
            return ds;
        }
        
        public DataTable GetFieldsByCategory(int CategoryId, int SchoolId,string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.CategoryId = CategoryId;
            StSetupBL.LangTool = LanguageTool;
            dt = StSetupBL.GetFieldsByCategory();
            return dt;
        }

        public int CheckDefaultAddressFieldCount(int FieldId)
        {
            int i = 0;
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldId = FieldId;            
            i = StSetupBL.CheckDefaultAddressFieldCount();
            return i;
        }
        
        public DataTable GetAddressFieldsByFieldId(int SchoolId, int FieldId,string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.FieldId = FieldId;
            StSetupBL.LangTool = LanguageTool;
            dt = StSetupBL.GetAddressFieldsByFieldId();
            return dt;
        }

        public DataTable GetSpecialEducation(int SchoolId,string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.LangTool = LanguageTool;
            dt = StSetupBL.GetSpecialEducation();
            return dt;
        }
        
        public DataTable GetGiftedEducation(int SchoolId,string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.LangTool = LanguageTool;
            dt = StSetupBL.GetGiftedEducation();
            return dt;
        }

        public DataTable GetAdditionalContact(int SchoolId,string LanguageTool)
        {
            DataTable dt = new DataTable();
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.LangTool = LanguageTool;
            dt = StSetupBL.GetAdditionalContact();
            return dt;
        }







        public void ControlAdd(string ExtraFieldId, string FieldName, string ControlType, int SchoolId, string StudentId, string StaffTypeId, string CategoryId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.ExtraFieldId = Convert.ToInt32(ExtraFieldId);
            StSetupBL.ControlType = Convert.ToInt32(ControlType);
            StSetupBL.FieldName = FieldName;
            StSetupBL.StudentId = Convert.ToInt32(StudentId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.StaffTypeId = Convert.ToInt32(StaffTypeId);
            StSetupBL.CategoryId = Convert.ToInt32(CategoryId);
            StSetupBL.ControlAdd();
           

           
        }

        public void AddDdlListItem(string ExtraFieldId, string DdlListitemName)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.ExtraFieldId = Convert.ToInt32(ExtraFieldId);
           
            StSetupBL.DdlListitemName = DdlListitemName;

            StSetupBL.AddDdlListItem();
        }

        public int getExtraFieldId()
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


           StSetupBL.getExtraFieldId();
           int i = StSetupBL.ExtraFieldId;
          return i;
        }

        public void deleteListItems(string ExtraFieldId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.ExtraFieldId = Convert.ToInt32(ExtraFieldId);



            StSetupBL.deleteListItems();
        }

        public void deletecustomfield(string ExtraFieldId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.ExtraFieldId = Convert.ToInt32(ExtraFieldId);



            StSetupBL.deletecustomfield();
        }

        public DataTable populatecustomfield(int SchoolId, int StudentId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.StudentId =StudentId;

            DataTable dt = StSetupBL.populatecustomfield();
            return dt;
        }

        public void AddCategory(string CategoryName, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.CategoryName = CategoryName;
            StSetupBL.SchoolId = SchoolId;

            StSetupBL.AddCategory();
           
        }

        public DataTable GetMaxCatergoryId()
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


          DataTable dt =   StSetupBL.GetMaxCatergoryId();

          return dt;
        }

        public void UpdateDefaultFieldStatus(string FieldStatus, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = FieldId;
            StSetupBL.SchoolId = SchoolId;

            StSetupBL.UpdateDefaultFieldStatus();
        }

        public void UpdateCustomFieldStatus(string FieldStatus, string FieldId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId =Convert.ToInt32( FieldId);


            StSetupBL.UpdateCustomFieldStatus();
        }

        public int CheckDefaultFieldCount(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.SchoolId = SchoolId;
            StSetupBL.FieldId = FieldId;


          int i =  StSetupBL.CheckDefaultFieldCount();
          return i;
        }

        public void InsertDefaultFieldStatus(int FieldId, string FieldStatus, int SchoolId, string FieldView)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = FieldView;

            StSetupBL.InsertDefaultFieldStatus();
        }

        public int CheckSpecialFieldFromStatusTable(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
           

          int i =  StSetupBL.CheckSpecialFieldFromStatusTable();
          return i;
        }

        public void UpdateDefaultSpecialFieldStatus(string FieldStatus, int FieldId, int SchoolId)
        {

            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
           

            StSetupBL.UpdateDefaultSpecialFieldStatus();
        }

        public void UpdateDefaultSpecialFieldView(string FieldView, int FieldId, int SchoolId)
        {

            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldView = FieldView;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);


            StSetupBL.UpdateDefaultSpecialFieldView();
        }

        public void Insertspecialfieldstatus(int FieldId, string FieldStatus, int SchoolId, string FieldView)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = FieldView;

            StSetupBL.Insertspecialfieldstatus();
        }

        public int CheckGiftedFieldFromStatusTable(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();

            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);


            int i = StSetupBL.CheckGiftedFieldFromStatusTable();
           return i;
        }

        public void UpdateDefaultGiftedFieldView(string FieldView, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();

            StSetupBL.FieldView = FieldView;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);


            StSetupBL.UpdateDefaultGiftedFieldView();
          
        }

        public void UpdateDefaultgiftedFieldViewStatus(string FieldStatus, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();

            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);


            StSetupBL.UpdateDefaultgiftedFieldViewStatus();
        }

        public void Insertgiftedfieldstatus(int FieldId, string FieldStatus, int SchoolId, string FieldView)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();

            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = FieldView;


            StSetupBL.Insertgiftedfieldstatus();
        }







        public int CheckAddressFieldFromStatusTable(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();

           
            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);


          int i =  StSetupBL.CheckAddressFieldFromStatusTable();
          return i;
        }

        public void UpdateDefaultAddressFieldStatus(string FieldStatus, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);



            StSetupBL.UpdateDefaultAddressFieldStatus();
            
        }

        public void InsertDefaultAddressFieldStatus(string FieldStatus, int FieldId, int SchoolId, string Fieldview)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = Fieldview;


            StSetupBL.InsertDefaultAddressFieldStatus();
        }

        public int CheckAdditionalContactList(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);

            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);



            int i = StSetupBL.CheckAdditionalContactList();
          return i;
        }

        public DataTable GetAdditionalContactFields(int FieldId, int SchoolId, string Langto)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);

            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);

            StSetupBL.LangTool = Langto;

            DataTable dt = StSetupBL.GetAdditionalContactFields();
            return dt;
        }

        public void UpdateAdditionalAddressFieldStatus(string FieldStatus, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);



            StSetupBL.UpdateAdditionalAddressFieldStatus();
        }

        public int CheckAdditionalAddressFieldFromStatusTable(int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            //StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);

            int i = StSetupBL.CheckAdditionalAddressFieldFromStatusTable();
            return i;
        }

        public void InsertAdditionalAddressFieldStatus(int FieldId, string FieldStatus, int SchoolId, string FieldView)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.FieldStatus = FieldStatus;
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = FieldView;


            StSetupBL.InsertAdditionalAddressFieldStatus();
        }

        public void UpdateDefaultFieldView(string FieldView, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
           
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);
            StSetupBL.FieldView = FieldView;


            StSetupBL.UpdateDefaultFieldView();
        }

        public void UpdateCustomFieldView(string FieldView, int FieldId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            
            StSetupBL.FieldView = FieldView;


            StSetupBL.UpdateCustomFieldView();
        }

        public void UpdateDefaultAddressFieldView(string FieldView, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);

            StSetupBL.FieldView = FieldView;


            StSetupBL.UpdateDefaultAddressFieldView();
        }

        public void UpdateAdditionalAddressFieldView(string FieldView, int FieldId, int SchoolId)
        {
            StudentSetupBL StSetupBL = new StudentSetupBL();


            StSetupBL.FieldId = Convert.ToInt32(FieldId);
            StSetupBL.SchoolId = Convert.ToInt32(SchoolId);

            StSetupBL.FieldView = FieldView;


            StSetupBL.UpdateAdditionalAddressFieldView();
        }
        //==========================  FORM LAYOUT IN STUDENT =======================================================

        public DataSet populatedynamicrchk(int FieldId)
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            EFLBL.FieldId = FieldId;
            ds = EFLBL.populatedynamicrchk();
            return ds;
        }

        public DataSet populatedynamicrbtn(int FieldId)
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            EFLBL.FieldId = FieldId;
            DataSet ds = new DataSet();
            ds = EFLBL.populatedynamicrbtn();
            return ds;
        }

        public DataSet populatedynamicddl(int FieldId)
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            EFLBL.FieldId = FieldId;
            DataSet ds = new DataSet();
            ds = EFLBL.populatedynamicddl();
            return ds;
        }

        public DataSet populateEthnicitySt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.populateEthnicity();
            return ds;
        }

        public DataSet populateLanguageSt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.populateLanguage();
            return ds;
        }

        public DataSet populateStateSt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.populateState();
            return ds;
        }

        public DataSet populateCountrySt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.populateCountry();
            return ds;
        }

        public DataSet PopulateEnrollCdnSt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.PopulateEnrollCdn();
            return ds;
        }

        public DataSet PopulateGenderSt()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataSet ds = new DataSet();
            ds = EFLBL.PopulateGender();
            return ds;
        }

        public DataTable GetSummaryFields()
        {
            EntryFormLayoutBL EFLBL = new EntryFormLayoutBL();
            DataTable dt = new DataTable();
            dt = EFLBL.GetSummaryFields();
            return dt;
        }

        public int SaveOrder(string fieldid, string schoolid, string sortorder, string def_cus, string catid)
        {
            DragNDrop DND = new DragNDrop();

            string Fieldid = fieldid;
            string Schoolid = schoolid;
            string Sortorder = sortorder;
            string Def_cus = def_cus;
            string Catid = catid;


            int i = DND.SaveOrder(Fieldid, Schoolid, Sortorder, Def_cus, Catid);
            return i;
          
        }

        public int SaveOrderview(string fieldid, string schoolid, string sortorder, string def_cus, string catid)
        {
            DragNDrop DND = new DragNDrop();

            string Fieldid = fieldid;
            string Schoolid = schoolid;
            string Sortorder = sortorder;
            string Def_cus = def_cus;
            string Catid = catid;


            int i = DND.SaveOrderview(Fieldid, Schoolid, Sortorder, Def_cus, Catid);
            return i;
        }






        public DataTable GetFieldsByCategoryEntryFormLayout(int SchoolId, int CategoryId, string Langto)
        {
            EntryFormLayoutBL EntryBL = new EntryFormLayoutBL();
            EntryBL.SchoolId = SchoolId;
            EntryBL.CategoryId = CategoryId;
            EntryBL.LangTool = Langto;
            DataTable dt = EntryBL.GetFieldsByCategory();
            return dt;
        }

        public DataTable GetAddressFieldsByFieldIdEntryFormLayout(int SchoolId, int FieldId, string Langto)
        {
            EntryFormLayoutBL EntryBL = new EntryFormLayoutBL();
            EntryBL.SchoolId = SchoolId;
            EntryBL.FieldId = FieldId;
            EntryBL.LangTool = Langto;

            DataTable dt = EntryBL.GetAddressFieldsByFieldId();
            return dt;
        }

        public DataTable GetAdditionalContactFieldsEntryFormLayout(int SchoolId, int FieldId, string Langto)
        {
            EntryFormLayoutBL EntryBL = new EntryFormLayoutBL();
            EntryBL.SchoolId = SchoolId;
            EntryBL.FieldId = FieldId;
            EntryBL.LangTool = Langto;

            DataTable dt = EntryBL.GetAdditionalContactFields();
            return dt;
        }
        //==========================  FORM LAYOUT IN STUDENT =======================================================
        //=======================  Student Information ================================================================


        public DataTable populatestudentlistbyschoolid(int SchoolID, string FName, string LName, string Gender, string Ethnicity, string DOB, string EnrollmentDate, string StdSchId)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.SchoolID = SchoolID;
            SIBL.FName = FName;
            SIBL.LName = LName;
            SIBL.Gender = Gender;
            SIBL.Ethnicity = Ethnicity;
            SIBL.DOB = DOB;
            SIBL.EnrollmentDate = EnrollmentDate;
            SIBL.StdSchId = StdSchId;
            dt = SIBL.populatestudentlistbyschoolid();
            return dt;
        }


        public DataTable GetFieldValueByCategory(int SchoolID, int StudentID, int CatID, string MLCulture)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            SIBL.CatId = CatID;
            SIBL.mlUICulture = MLCulture;
            dt = SIBL.GetFieldValueByCategory();
            return dt;
        }

        public DataTable GetSummaryFieldsStudentInfo(int StudentID, string MLCulture)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.StudentID = StudentID;
            SIBL.mlUICulture = MLCulture;
            dt = SIBL.GetSummaryFields();
            return dt;
        }

        public DataTable GetSummaryHeaderFields(int StudentID, string MLCulture)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.StudentID = StudentID;
            SIBL.mlUICulture = MLCulture;
            dt = SIBL.GetSummaryHeaderFields();
            return dt;
        }

        public DataTable GetPhotoURL(int SchoolID, int StudentID)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            DataTable dt = SIBL.getphotoURL();
            return dt;
        }

        public DataTable getgender(string Gender)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.Gender = Gender;
            dt = SIBL.getgender();
            return dt;
        }

        public DataTable getlanguage(int Language)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.Language = Language;
            dt = SIBL.getlanguage();
            return dt;
        }

        public DataTable getcountry(int CountryCode)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.CountryCode = CountryCode;
            dt = SIBL.getcountry();
            return dt;
        }

        public DataTable getstartcondition(string StartCondition)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.StartCondition = StartCondition;
            dt = SIBL.getstartcondition();
            return dt;
        }

        public DataTable getcustomlistitemname(int ListItemID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.ListItemId = ListItemID;
            dt = SIBL.getcustomlistitemname();
            return dt;
        }

        public DataTable getcontroltype(int FieldID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.FieldId = FieldID;
            dt = SIBL.getcontroltype();
            return dt;
        }

        public DataTable Getstudentschoolenroll(int StudentID, int SchoolId)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.StudentID = StudentID;
            SIBL.SchoolID = SchoolId;
            dt = SIBL.Getstudentschoolenroll();
            return dt;
        }

        public DataTable GetMedicalInfoFieldValue(int SchoolID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            dt = SIBL.GetMedicalInfoFieldValue();
            return dt;
        }

        public DataTable GetImmunizationFieldValue(int SchoolId, int StudentId)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.StudentID = StudentId;
            SIBL.SchoolID = SchoolId;
            dt = SIBL.GetImmunizationFieldValue();
            return dt;
        }

        public DataTable GetMedicalAlertFieldValue(int StudentID)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.StudentID = StudentID;
            dt = SIBL.GetMedicalAlertFieldValue();
            return dt;
        }

        public DataTable GetNurseVisitFieldValue(int SchoolId, int StudentId)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolId;
            SIBL.StudentID = StudentId;
            dt = SIBL.GetNurseVisitFieldValue();
            return dt;
        }

        public DataTable getethnicity(int EthnicityId)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.EthnicityId = EthnicityId;
            dt = SIBL.getethnicity();
            return dt;
        }

        public DataTable getcalendername(string Calendar, int School_Id)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.Calender = Calendar;
            SIBL.SchoolID = School_Id;
            dt = SIBL.getcalendername();
            return dt;
        }

        public DataTable getdefaultaddressfields(int SchoolID, int StudentID, string MLUILang)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            SIBL.mlUICulture = MLUILang;
            dt = SIBL.getdefaultaddressfields();
            return dt;
        }

        public DataTable getaddressfieldvalues(int SchoolID, int FieldID, string MLUILang)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.FieldId = FieldID;
            SIBL.mlUICulture = MLUILang;
            dt = SIBL.getaddressfieldvalues();
            return dt;
        }

        public DataTable GetAdditionalAddressContactSet(int SchoolID, int StudentID)
        {
            DataTable dt = new DataTable();
            StudentEditInfoBL SIEBL = new StudentEditInfoBL();
            SIEBL.SchoolID = SchoolID;
            SIEBL.StudentID = StudentID;
            dt = SIEBL.GetAdditionalAddressContactSet();
            return dt;
        }

        public DataTable PopulateAdditionalField(int SchoolID, int Homefieldid,string LangTool)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.HomeFieldId = Homefieldid;
            SIBL.mlUICulture = LangTool;
            dt = SIBL.PopulateAdditionalField();
            return dt;
        }

        public DataTable PopulateFieldValue(int Catd, int SchoolID, int StudentID)
        {
            DataTable dt = new DataTable();
            StudentEditInfoBL SEIBL = new StudentEditInfoBL();
            SEIBL.CatId = Catd;
            SEIBL.SchoolID = SchoolID;
            SEIBL.StudentID = StudentID;
            dt = SEIBL.PopulateFieldValue();
            return dt;
        }

        public DataTable PopulateAddressFields(int SchoolID, int StudentId, int CatId)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentId;
            SIBL.CatId = CatId;
            dt = SIBL.PopulateAddressFields();
            return dt;
        }

        public DataTable GetStateName(string State)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.State = State;
            dt = SIBL.getstatename();
            return dt;
        }

        public DataTable getcontactrelationshipname(string PersonRelID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.PersonRelId = PersonRelID;
            dt = SIBL.getcontactrelationshipname();
            return dt;
        }

        public DataTable GetVaccinationFieldValue(int SchoolID, int StudentID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            dt = SIBL.GetVaccinationFieldValue();
            return dt;
        }

        public string GetdynamicallycreatedDataItems(int ExtrafieldId, int ListItemId)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.ExtrafieldId = ExtrafieldId;
            SIBL.ListItemId = ListItemId;
            string s = SIBL.GetdynamicallycreatedDataItems();
            return s;
        }

        public DataTable GetSpecialValues(int SchoolID, int StudentId, int CatId)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentId;
            SIBL.CatId = CatId;
            dt = SIBL.GetSpecialValues();
            return dt;
        }

        public DataTable GetGiftedValues(int SchoolID, int StudentId, int CatId)
        {
            StudentInfoBL SIBL = new StudentInfoBL();
            DataTable dt = new DataTable();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentId;
            SIBL.CatId = CatId;
            dt = SIBL.GetGiftedValues();
            return dt;
        }

        public DataTable GetNextStudentId(int SchoolID, int StudentID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            dt = SIBL.getnextstudentid();
            return dt;
        }

        public DataTable GetPreviousStudentId(int SchoolID, int StudentID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            SIBL.StudentID = StudentID;
            dt = SIBL.getpreviousstudentid();
            return dt;
        }

        public DataTable GetLastStudentIdBySchoolId(int SchoolID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            dt = SIBL.getlaststudentidbyschoolid();
            return dt;
        }


        public DataTable GetFirstStudentIdBySchoolIId(int SchoolID)
        {
            DataTable dt = new DataTable();
            StudentInfoBL SIBL = new StudentInfoBL();
            SIBL.SchoolID = SchoolID;
            dt = SIBL.getfirststudentidbyschoolid();
            return dt;
        }

        //========================== View FORM LAYOUT IN STUDENT =======================================================
        public DataTable GetFieldsByCategoryViewFormLayout(int SchoolId, int CategoryId, string Langto)
        {
            ViewFormLayoutBL VMBL = new ViewFormLayoutBL();
            VMBL.SchoolId = SchoolId;
            VMBL.CategoryId = CategoryId;
            VMBL.LangTool = Langto;
            DataTable dt = VMBL.GetFieldsByCategory();
            return dt;
        }

        public DataTable GetAddressFieldsByFieldIdViewFormLayout(int SchoolId, int FieldId, string Langto)
        {
            ViewFormLayoutBL VMBL = new ViewFormLayoutBL();
            VMBL.SchoolId = SchoolId;
            VMBL.FieldId = FieldId;
            VMBL.LangTool = Langto;
            DataTable dt = VMBL.GetAddressFieldsByFieldId();
            return dt;
        }

        public DataTable GetAdditionalContactFieldsViewFormLayout(int SchoolId, int FieldId, string Langto)
        {
            ViewFormLayoutBL VMBL = new ViewFormLayoutBL();
            VMBL.SchoolId = SchoolId;
            VMBL.FieldId = FieldId;
            VMBL.LangTool = Langto;
            DataTable dt = VMBL.GetAdditionalContactFields();
            return dt;
        }
        //========================== View FORM LAYOUT IN STUDENT =======================================================


        //========================== Add Student FORM LAYOUT IN STUDENT =======================================================

      

        //========================== Add Student =======================================================
            
        public int StudentAddStudentBusiness(int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.SchoolID = Convert.ToInt32(SchoolID);
            int i = StuBL.StudentAdd();
            return i;
        }

        public DataTable populaterepeaterStudentBusiness(int ExtrafieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = Convert.ToInt32(ExtrafieldId);
            DataTable dt = StuBL.populaterepeater();
            return dt;
        }

        public void SaveCustomDataStudentBusiness(string CustomfieldValue, int StudentID, int ExtrafieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = Convert.ToInt32(ExtrafieldId);
            StuBL.CustomfieldValue = CustomfieldValue;
            StuBL.StudentID = Convert.ToInt32(StudentID);
            StuBL.SaveCustomData();            
        }

        public DataTable populatecalenderStudentBusiness(int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = Convert.ToInt32(SchoolID);
            DataTable dt = StuBL.populatecalender();
            return dt;
        }

        public DataTable populateLanguageStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();          
            DataTable dt = StuBL.populateLanguage();
            return dt;
        }

        public DataTable populateEthnicityStudentBusiness(string LangTool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.LangTool = LangTool;
            DataTable dt = StuBL.populateEthnicity();
            return dt;
        }

        public DataTable populatedynamicddlStudentBusiness(int ExtrafieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = ExtrafieldId;
            DataTable dt = StuBL.populatedynamicddl();
            return dt;
        }

        public DataTable populatedynamicrbtnStudentBusiness(int ExtrafieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = ExtrafieldId;
            DataTable dt = StuBL.populatedynamicrbtn();
            return dt;
        }

        public DataTable populatedynamicrchkStudentBusiness(int ExtrafieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.ExtrafieldId = ExtrafieldId;
            DataTable dt = StuBL.populatedynamicrchk();
            return dt;
        }

        public DataTable PopulateGradeStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();          
            DataTable dt = StuBL.populatedynamicrchk();
            return dt;
        }

        public DataTable PopulateEnrollCdnStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateEnrollCdn();
            return dt;
        }

        public DataTable propulateSchoolStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.propulateSchool();
            return dt;
        }

        public string GetSchoolNamefromIDStudentBusiness(int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.SchoolID = SchoolID;
            StuBL.GetSchoolNamefromID();
            return StuBL.SchoolName;
        }

        public int getStudentIdStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();            
            StuBL.getStudentId();
            return StuBL.StudentID;
        }

        public DataTable PopulateGenderStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();           
            DataTable dt = StuBL.PopulateGender();
            return dt;
        }

        public void SavecontrolorderStudentBusiness(string FieldName, int StudentID, int ExtrafieldId, string CustomfieldValue, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.FieldName = FieldName;
            StuBL.StudentID = StudentID;
            StuBL.ExtrafieldId = ExtrafieldId;
            StuBL.CustomfieldValue = CustomfieldValue;
            StuBL.SchoolID = SchoolID;
            StuBL.Savecontrolorder();
           
        }

        public DataTable GetNextCategoryStudentBusiness(int SchoolID, int CatId)
        {
            StudentBL StuBL = new StudentBL();            
            StuBL.CatId = CatId;            
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetNextCategory();
            return dt;
        }

        public DataTable GetPrevCategoryStudentBusiness(int SchoolID, int CatId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.CatId = CatId;
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetPrevCategory();
            return dt;
        }   

        public DataTable GetFieldsByCategoryStudentBusiness(int SchoolID, int CatId,string langtool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.CatId = CatId;
            StuBL.SchoolID = SchoolID;
            StuBL.LangTool = langtool;
            DataTable dt = StuBL.GetFieldsByCategory();
            return dt;
        }

        public DataTable GetFirstCategoryStudentBusiness(int SchoolID)
        {
            StudentBL StuBL = new StudentBL();  
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetFirstCategory();
            return dt;
        }

        public int CheckAddressFieldStudentBusiness(int FieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.FieldId = FieldId;
            int i = StuBL.CheckAddressField();
            return i;
        }

        public DataTable GetAddressFieldsByFieldIdStudentBusiness(int SchoolID, int FieldId,string LangTool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.FieldId = FieldId;
            StuBL.SchoolID = SchoolID;
            StuBL.LangTool = LangTool;
            DataTable dt = StuBL.GetAddressFieldsByFieldId();
            return dt;
        }

        public int AddStudentStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            int i = StuBL.AddStudent();
            return i;
        }

        public void AddStudentdataStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
             StuBL.AddStudentdata();            
        }

        public DataTable PopulateAdditionalFieldStudentBusiness(int SchoolID, int HomeFieldId,string Langtool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.HomeFieldId = HomeFieldId;
            StuBL.SchoolID = SchoolID;
            StuBL.LangTool = Langtool;
            DataTable dt = StuBL.PopulateAdditionalField();
            return dt;
        }

        public void InsertIntoStudentDetailsStudentBusiness(int StudentID, string FieldCategory, int FieldId, string Value, int CatId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.FieldCategory = FieldCategory;
            StuBL.FieldId = FieldId;
            StuBL.Value = Value;
            StuBL.CatId = CatId;
            StuBL.InsertIntoStudentDetails();            
        }

        public DataTable PopulateContactRelationshipStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt =  StuBL.PopulateContactRelationship();
            return dt;
        }

        public void InsertIntoStudentAdddressDetailsStudentBusiness(int StudentID, int AddId, string Value, int FieldId, int CatId, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.AddId = AddId;
            StuBL.Value = Value;
            StuBL.FieldId = FieldId;
            StuBL.CatId = CatId;
            StuBL.SchoolID = SchoolID;
            StuBL.InsertIntoStudentAdddressDetails();
        }

        public void InsertIntoStudentAdditionalContactStudentBusiness(int CatId, int StudentID, int FieldId, string Value, int Set, int SchoolID, int ContSetId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;

            StuBL.CatId = CatId;
            StuBL.StudentID = StudentID;
            StuBL.FieldId = FieldId;
            StuBL.Value = Value;
            StuBL.Set = Set;
            StuBL.SchoolID = SchoolID;
            StuBL.ContSetId = ContSetId;
            StuBL.InsertIntoStudentAdditionalContact();
        }

        public void SaveStudentPhotoStudentBusiness(int StudentID, int SchoolID, string PhotoUrl)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            StuBL.PhotoUrl = PhotoUrl;
            StuBL.SaveStudentPhoto();
        }

        public int CountSetFieldsStudentBusiness(int StudentID, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            int i = StuBL.CountSetFields();
            return i;
        }

        public DataTable GetVaccinationFieldsStudentBusiness(int SchoolID, int CatId)
        {
            StudentBL StuBL = new StudentBL();  
            StuBL.CatId = CatId;
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetVaccinationFields();
            return dt;
        }

        public DataTable GetMedicalInfoFieldsStudentBusiness(int SchoolID, int CatId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.CatId = CatId;
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetMedicalInfoFields();
            return dt;
        }

        public void InsertIntoStudentMedicalInformationDetailsStudentBusiness(int StudentID, int SchoolID, string Value, int MedInfoId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            StuBL.Value = Value;
            StuBL.MedInfoId = MedInfoId;
            StuBL.InsertIntoStudentMedicalInformationDetails();            
        }

        public void InsertIntoStudentImmunizationDetailsStudentBusiness(int MedInfoType, string MedInfoDate, string Comments, int SchoolID, int StudentID, int FieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.MedInfoType = MedInfoType;
            StuBL.MedInfoDate = MedInfoDate;
            StuBL.Comments = Comments;
            StuBL.SchoolID = SchoolID;
            StuBL.StudentID = StudentID;
            StuBL.FieldId = FieldId;
            StuBL.InsertIntoStudentImmunizationDetails();
        }

        public void InsertIntoStudentNurseVisitRecordDetailsStudentBusiness(string NurseVisitDate, string NurseVisitTimeIn, string NurseVisitTimeOut, string NurseVisitReason, string NurseVisitResult, string Comments, int StudentID, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.NurseVisitDate = NurseVisitDate;
            StuBL.NurseVisitTimeIn = NurseVisitTimeIn;
            StuBL.NurseVisitTimeOut = NurseVisitTimeOut;
            StuBL.NurseVisitReason = NurseVisitReason;
            StuBL.NurseVisitResult = NurseVisitResult;
            StuBL.Comments = Comments;
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            StuBL.InsertIntoStudentNurseVisitRecordDetails();
        }

        public void InsertIntoStudentVaccinationRecordDetailsStudentBusiness(int StudentID, int SchoolID, string Value, int FieldId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            StuBL.Value = Value;
            StuBL.FieldId = FieldId;
            StuBL.InsertIntoStudentVaccinationRecordDetails();
        }

        public void InsertIntoStudentMedicalAlertStudentBusiness(int StudentID, int MedAlertActId, string Value, int LifeThreatInd)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StudentID;
            StuBL.MedAlertActId = MedAlertActId;
            StuBL.Value = Value;
            StuBL.LifeThreatInd = LifeThreatInd;
            StuBL.InsertIntoStudentMedicalAlert();
        }

        public void InsertEnrollmentStudentBusiness(string EnrAttStartdate, string EnrExitDate, int StudentID, int SchoolID, int EnrSchyrId, string EnrExitCode, string EnrExitreason, string EnrStartCondition)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.EnrAttStartdate = EnrAttStartdate;
            StuBL.EnrExitDate = EnrExitDate;
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            StuBL.EnrSchyrId = EnrSchyrId;
            StuBL.EnrExitCode = EnrExitCode;
            StuBL.EnrExitreason = EnrExitreason;
            StuBL.EnrStartCondition = EnrStartCondition;
            StuBL.InsertEnrollment();
        }

        public DataTable GetstudentschoolenrollStudentBusiness(int StudentID, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();            
            StuBL.StudentID = StudentID;
            StuBL.SchoolID = SchoolID;
            DataTable dt =   StuBL.Getstudentschoolenroll();
            return dt;
        }

        public void UpdateEnrollmentStudentBusiness(string EnrAttStartdate, string EnrEndDate, string EnrExitCode, string EnrExitreason, string EnrStartCondition, int EnrollId)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.EnrAttStartdate = EnrAttStartdate;
            StuBL.EnrEndDate = EnrEndDate;
            StuBL.EnrExitCode = EnrExitCode;
            StuBL.EnrExitreason = EnrExitreason;
            StuBL.EnrStartCondition = EnrStartCondition;
            StuBL.EnrollId = EnrollId;
            StuBL.UpdateEnrollment();           
        }

        public void DeleteEnrollmentStudentBusiness(int EnrollId)
        {
            StudentBL StuBL = new StudentBL();           
            StuBL.EnrollId = EnrollId;
            StuBL.DeleteEnrollment();
        }

        public DataTable PopulateSpecialFieldStudentBusiness(int SchoolID, string Langtool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.SchoolID = SchoolID;
            StuBL.LangTool = Langtool;
            DataTable dt = StuBL.PopulateSpecialField();
            return dt;
        }

        public DataTable PopulateGiftFieldStudentBusiness(int SchoolID, string Langtool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.SchoolID = SchoolID;
            StuBL.LangTool = Langtool;
            DataTable dt = StuBL.PopulateGiftField();
            return dt;
        }      

        public DataTable PopulateEvaluationTypeStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateEvaluationType();
            return dt;
        }

        public DataTable PopulateDisabilitiesStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateDisabilities();
            return dt;
        }

        public DataTable PopulateGiftedCategoryStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateGiftedCategory();
            return dt;
        }

        public DataTable PopulateSpecialEduStatusStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateSpecialEduStatus();
            return dt;
        }

        public DataTable PopulateSpecialEduExistStatusStudentBusiness()
        {
            StudentBL StuBL = new StudentBL();
            DataTable dt = StuBL.PopulateSpecialEduExistStatus();
            return dt;
        }

        public void InsertSpecialValueStudentBusiness(int FieldId, int CatId, int StudentID, string Value, int SchoolID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.FieldId = FieldId;
            StuBL.CatId = CatId;
            StuBL.StudentID = StudentID;
            StuBL.Value = Value;
            StuBL.SchoolID = SchoolID;                
            StuBL.InsertSpecialValue();
        }

        public void InsertgiftedValueStudentBusiness(int FieldId, int CatId, string Value, int SchoolID, int StudentID)
        {
            StudentBL StuBL = new StudentBL();

            StuBL.FieldId = FieldId;
            StuBL.CatId = CatId;
            StuBL.StudentID = StudentID;
            StuBL.Value = Value;
            StuBL.SchoolID = SchoolID;
            StuBL.InsertgiftedValue();
        }

        public DataTable GetSchoolSpecificCategoryStudentBusiness(string SchoolId, string LanguageTool)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.SchoolID = Convert.ToInt32(SchoolId);
            StuBL.LangTool = LanguageTool;
            DataTable dt = StuBL.GetSchoolSpecificCategory();
            return dt;
        }

        //========================== Edit Student =======================================================
        

        public DataTable PopulateFieldValueStudentEdit(int SchoolID, int CatId, int StudentID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.SchoolID = SchoolID;
            STEDIT.CatId = CatId;
            STEDIT.StudentID = StudentID;
            DataTable dt = STEDIT.PopulateFieldValue();
            return dt;
        }

        public void UpdateStudentDetailsStudentEdit(string Value, int CatId, int StudentID, int FieldId, string FieldCategory)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.Value = Value;
            STEDIT.CatId = CatId;
            STEDIT.StudentID = StudentID;
            STEDIT.FieldId = FieldId;
            STEDIT.FieldCategory = FieldCategory;
            STEDIT.UpdateStudentDetails();          
        }

        public DataTable GetSchoolSpecificCategoryStudentEdit(int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.SchoolID = SchoolID;
            DataTable dt =   STEDIT.GetSchoolSpecificCategory();
            return dt;
        }

        public DataTable PopulateAddressFieldsStudentEdit(int StudentID, int CatId, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.CatId = CatId;
            STEDIT.SchoolID = SchoolID;
            DataTable dt = STEDIT.PopulateAddressFields();
            return dt;
        }

        public DataTable PopulateAdditionalAddressFieldsStudentEdit(int StudentID, int CatId, int SchoolID, int Set)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.CatId = CatId;
            STEDIT.SchoolID = SchoolID;
            STEDIT.Set = Set;
            DataTable dt = STEDIT.PopulateAdditionalAddressFields();
            return dt;
        }

        public DataTable GetAdditionalAddressContactSetStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            DataTable dt = STEDIT.GetAdditionalAddressContactSet();
            return dt;
        }

        public void UpdateAddressDetailsStudentEdit(string Value, int StudentID, int CatId, int SchoolID, int AddId)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.Value = Value;
            STEDIT.CatId = CatId;
            STEDIT.AddId = AddId;
            STEDIT.UpdateAddressDetails();            
        }

        public void UpdateAdditionalContactDetailsStudentEdit(string Value, int StudentID, int Set, int SchoolID, int ContSetId)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.Value = Value;
            STEDIT.Set = Set;
            STEDIT.ContSetId = ContSetId;
            STEDIT.UpdateAdditionalContactDetails();
        }

        public int CountSetFieldsStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            return  STEDIT.CountSetFields();
        }

        public void UpdateStudentPhotoStudentEdit(string PhotoUrl, int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.PhotoUrl = PhotoUrl;
            STEDIT.UpdateStudentPhoto();
        }

        public int GetPhotoCountStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            return STEDIT.GetPhotoCount();
        }

        public int CheckFieldValuesStudentEdit(int FieldId, int CatId, int StudentID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.FieldId = FieldId;
            STEDIT.CatId = CatId;
            return STEDIT.CheckFieldValues();
        }

        public DataTable PopulateMedicalInfoValueStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            return STEDIT.PopulateMedicalInfoValue();
        }

        public void DeleteAllMedicalInformationStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.DeleteAllMedicalInformation();
        }

        public void UpdateMedicalInfoStudentEdit(string Value, int SchoolID, int StudentID, int MedInfoId)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.Value = Value;
            STEDIT.SchoolID = SchoolID;
            STEDIT.StudentID = StudentID;
            STEDIT.MedInfoId = MedInfoId;
            STEDIT.UpdateMedicalInfo();
        }

        public DataTable PopulateSchoolFieldValueStudentEdit(int CatId, int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.CatId = CatId;
            STEDIT.SchoolID = SchoolID;
            STEDIT.StudentID = StudentID;  
            return  STEDIT.PopulateSchoolFieldValue();
        }

        //****************
        public void DeleteProgramsSpecialEducationDetailsStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.DeleteProgramsSpecialEducationDetails();
        }

        public void DeleteProgramsGiftedDetailsStudentEdit(int StudentID, int SchoolID)
        {
            StudentEditInfoBL STEDIT = new StudentEditInfoBL();
            STEDIT.StudentID = StudentID;
            STEDIT.SchoolID = SchoolID;
            STEDIT.DeleteProgramsGiftedDetails();
        }

        //*******26/04/2010********
        public DataTable ExitCallenderDetails(int CalenderID, int SchoolID)
        {
            CalenderDetailsBL CalBL = new CalenderDetailsBL();
            CalBL.CalenderID = CalenderID;
            CalBL.SchoolID = SchoolID;
            return CalBL.ExistCallenderDetailsSchedule();
        }

        public DataTable GetVaccinationFieldsValue(int SchoolID, int StubentID)
        {
            StudentBL StuBL = new StudentBL();
            StuBL.StudentID = StubentID;
            StuBL.SchoolID = SchoolID;
            DataTable dt = StuBL.GetVaccinationfieldsWithValue();
            return dt;
        }

        
        public void UpdateCategoryNameAndOrder(int Cat_ID, int Short_Order, string Cat_Name, int Previous_Order)
        {
            StudentSetupBL SSBL = new StudentSetupBL();
            SSBL.CategoryId = Cat_ID;
            SSBL.SortOrder = Short_Order;
            SSBL.CategoryName = Cat_Name;
            SSBL.PreviousOrder = Previous_Order;
            SSBL.UpdateCategoryAndOrder();           
        }

        //***************
        public void AddEthinicity(string Ethnicity_Short_Name, string Ethnicity_Name, string Last_Update_Date, int SchID)
        {
            EthnicityBL EthBL = new EthnicityBL();
            EthBL.EthnicityShortName = Ethnicity_Short_Name;
            EthBL.EthnicityName = Ethnicity_Name;
            EthBL.LastUpdated = Last_Update_Date;
            EthBL.SchoolID = SchID;
            EthBL.AddEthnicity();
        }

        public void UpdateEthinicity(string Ethnicity_Short_Name, string Ethnicity_Name, string Last_Update_Date, int EthID)
        {
            EthnicityBL EthBL = new EthnicityBL();
            EthBL.EthnicityShortName = Ethnicity_Short_Name;
            EthBL.EthnicityName = Ethnicity_Name;
            EthBL.LastUpdated = Last_Update_Date;           
            EthBL.EthnicityID = EthID;
            EthBL.UpdateEthnicity();
        }

        public DataTable PopulateEthnicityDetails(string Ethnicity_Short_Name, string Ethnicity_Name,int SchID)
        {
            EthnicityBL EthBL = new EthnicityBL();
            EthBL.EthnicityShortName = Ethnicity_Short_Name;
            EthBL.EthnicityName = Ethnicity_Name;
            EthBL.SchoolID = SchID;
            DataTable dt = EthBL.PopulateEthnicity();
            return dt;
        }

        public void UpdateEthnicityFlag(string Ethnicity_Flag, string Last_Update_Date, int EthID)
        {
            EthnicityBL EthBL = new EthnicityBL();
            EthBL.Flag = Ethnicity_Flag;
            EthBL.EthnicityID = EthID;
            EthBL.LastUpdated = Last_Update_Date;
            EthBL.UpdateEthnicityFlag();
        }

        public void UpdateShortOrderEthnicity(string Sortorder, int EthID)
        {
            EthnicityBL EthBL = new EthnicityBL();
            EthBL.EthnicityID = EthID;
            EthBL.ShortOrder = Sortorder;
            EthBL.UpdateShortOrder();
        }        
       
    }
}
